package com.gitee.attendance.entity;

import java.io.FileInputStream;

import javax.persistence.Entity;

import com.gitee.attendance.util.base64.Base64Util;

import org.springframework.beans.factory.annotation.Autowired;

@Entity
public class User {

    private String UserCode;

    private String UserName;

    private String UserFace;

    @Autowired
    private Base64Util base64Util;

    /** 
     * @param REDIS_KEY the user:
     */
    public static String REDIS_KEY = "user:";
    /** 
     * @param REDIS_NMAE the user
     */
    public static String REDIS_NMAE = "user";
    /**
     * @param USERNAME the userName
     */
    public static String USERNAME = "userName";
    /**
     * @param USERCODE the userCode
     */
    public static String USERCODE = "userCode";
    /**
     * @param USERFACE the userFace
     */
    public static String USERFACE = "userFace";
    
    /**
     * @param userCode the userCode to set
     */
    public void setUserCode(String userCode) {
        UserCode = userCode;
    }

    /**
     * @return the userCode
     */
    public String getUserCode() {
        return UserCode;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        UserName = userName;
    }

    /**
     * @return the userName
     */
    public String getUserName() {
        return UserName;
    }

    /**
     * @param userFace the userFace to set
     */
    public void setUserFace(String userFace) {
        UserFace = userFace;
    }

    public void setUserFace(FileInputStream userFace) throws Exception {
        base64Util = new Base64Util();
        byte[] bytes1 = base64Util.getFileInputStream(userFace);
        setUserFace(bytes1);
    }

    public void setUserFace(byte[] userFace) throws Exception {
        base64Util = new Base64Util();
        String base1 = base64Util.encode(userFace);
        setUserFace(base1);
    }

    /**
     * @return the userFace
     */
    public String getUserFace() {
        return UserFace;
    }
}